package da.metricscraft.client;

import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import da.metricscraft.client.frames.GraphicsPanel;
import da.metricscraft.client.frames.LoadingPanel;
import da.metricscraft.client.frames.SwitchPanel;

public class MetricsCraftClient extends JFrame {
	/**
	 * 
	 */
	private static MetricsCraftClient singleton;
	public static MetricsCraftClient getInstance(){
		return singleton;
	}
	private static final long serialVersionUID = 7206470521534018636L;
	public MetricsCraftClient(){
		super("MetricsCraft Client");
		singleton = this;
		MetricsCraftClient.setNativeLookAndFeel(this);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(1280, 720);
		
		setLayout(new FlowLayout());
		setLocation(Toolkit.getDefaultToolkit().getScreenSize().width/2 - 1280/2, Toolkit.getDefaultToolkit().getScreenSize().height/2 - 720/2);
		getContentPane().add(LoadingPanel.getInstance());
		getContentPane().add(SwitchPanel.getInstance());
	}

	public static void main(String[] args){
		MetricsCraftClient mcc = new MetricsCraftClient();
		mcc.pack();
		mcc.setVisible(true);
	}
	public static void setNativeLookAndFeel(Component tree) {
		try {
		    UIManager.setLookAndFeel(
		        UIManager.getSystemLookAndFeelClassName());
		    SwingUtilities.updateComponentTreeUI(tree);
		} catch (UnsupportedLookAndFeelException ex) {
		  System.out.println("Unable to load native look and feel");
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
